package com.glorysoft.knowlespda.ui.jobinfo.viewmodel

import android.app.Activity
import androidx.databinding.ObservableArrayList
import com.glorysoft.knowlespda.BR
import com.glorysoft.knowlespda.R
import com.glorysoft.knowlespda.base.BaseViewModel
import com.glorysoft.knowlespda.base.Constant
import com.glorysoft.knowlespda.entity.BoardIdEntity
import com.glorysoft.knowlespda.entity.LotEntity
import com.glorysoft.knowlespda.entity.ui.CallObserveBean
import com.glorysoft.knowlespda.model.TrackRepository
import com.glorysoft.knowlespda.utils.MyUtils
import com.google.gson.Gson
import com.google.gson.JsonObject
import com.google.gson.reflect.TypeToken
import com.pda.platform.ui.ui_pdaplatform.entity.FreeUI_TabIndexGridEntity
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_StringUtils
import me.tatarka.bindingcollectionadapter2.ItemBinding
import java.io.InputStream

/**
 * FileName: HomeViewModel
 * Author: XJH
 * Date: 2021/7/12 17:20
 * Description:
 * History:
 */
class JobInfoViewModel: BaseViewModel() {

    val repository = TrackRepository()

    var lotData = LotEntity()

    var bomItems = ObservableArrayList<String>()
    var bomBinding =
        ItemBinding.of<String>(BR.bomItem, R.layout.item_job_info)

    fun getJobInfo(MAGAZINENO: String) {
        var map = JsonObject()
        map.addProperty("OPID", Constant.CURRENT_USER)
        map.addProperty("PDANO", Constant.PDA_NO)
        map.addProperty("MAGAZINENO", MAGAZINENO)
        launchOnlyResult({
            lotData = repository.getJobInfo(map)
            defUI.callObserve.value = CallObserveBean(0, lotData)

            if (lotData.BOARDSID.isNotEmpty()) {
                val split = lotData.BOARDSID.split(";")
                split.forEach {
                    bomItems.add(it)
                }
            }
        })
    }
}